package com.metaera.app.ui.fragments;

import android.os.Bundle;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.metaera.app.Constants;
import com.metaera.app.controller.core.IPaginationPresenter;
import com.metaera.app.controller.presenter.CalendarItemListPresenter;
import com.metaera.app.controller.view.core.IPaginationView;
import com.metaera.app.data.model.ArticleListResponse;
import com.metaera.app.ui.adapters.FlashNewsCalendarItemAdapter;
import com.metaera.app.ui.core.BaseRequestListFragment;

import java.util.Objects;

import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;


public class FlashNewsCalendarItemFragment extends BaseRequestListFragment<ArticleListResponse> {

    public static Fragment newInstance(int type) {
        Bundle bundle = new Bundle();
        bundle.putInt(Constants.CATEGORY_TYPE, type);
        FlashNewsCalendarItemFragment fragment = new FlashNewsCalendarItemFragment();
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    protected BaseQuickAdapter<ArticleListResponse, BaseViewHolder> createAdapter(RecyclerView recyclerView) {
        return new FlashNewsCalendarItemAdapter();
    }

    @Override
    protected IPaginationPresenter<IPaginationView<ArticleListResponse>, ArticleListResponse> createPresenter() {
        Bundle arguments = getArguments();
        int categoryType = Objects.requireNonNull(arguments).getInt(Constants.CATEGORY_TYPE);
        return new CalendarItemListPresenter(categoryType);
    }

    public void set(String date){
        if (mPresenter != null){
            ((CalendarItemListPresenter) mPresenter).setParamsAndExecute(date);
        }
    }

}
